<?PHP
class xmlResult
{
	private $message = '';
	private $details = '';
	private $type = 'error';
	
	public function __construct($message, $type='error')
	{
		$this->message = $message;
		$this->type = $type;
	}
	
	public function setDetails($details, $cdata=false)
	{
		if ( $cdata )
		{
			$this->details = '<![CDATA[' . $details . ']]>';
		}
		else
		{
			$this->details = $details;
		}
	}
	
	public function toXML()
	{
		$result = "<result>";
		$result .= "<type>{$this->type}</type>";
		$result .= "<message>{$this->message}</message>";
		$result .= "<details>{$this->details}</details>";
		$result .= "</result>";
		
		return $result;
	}
	
	public function exitResult()
	{
		print($this->toXML());
		
		exit();
	}
}
?>